<!--
 * @Author: yaru
 * @Date: 2024-05-13 10:51:58
 * @LastEditors: yaru
 * @LastEditTime: 2024-05-13 20:49:49
 * @FilePath: \zmglpt-ui-mobile-v1.1\dev\pages\store\goods\goodsList.vue
 * @Description: 涉案物品列表
-->

<template>
	<view class="">
		<!-- #ifdef H5-ONLY -->
		<theme-navbar :is-white="false" :custom-back="goBack" style="z-index: 99999" :title="navTitle">
		</theme-navbar>
		<!-- #endif -->
        <view class="nolicence-search-lay" :style="{'top': isHideNav ? 0 : '44px'}">
            <view class="nolicenSearch">
                <u-search
                shape="round"
                :clearabled="true"
                :showAction="true"
                actionText="确定"
                :animation="true"
                :placeholder="plTitle"
                v-model="searchKey"
                @custom="toSearchList"
                ></u-search>
            </view>
        </view>
		<view class="content u-page">
			<me-table :i="0" :index="0" :top="10" :load-data="loadData" :height="getListViewHeight()" :init-load="false" ref="mescrollItem0">
				<view slot-scope="d" class="list-item-root">
					<view class="list-lay">
						<goodsListItem :itemInfo="d.data"></goodsListItem>
					</view>
				</view>
			</me-table>
		</view>
	</view>
</template>


<script>
	import MescrollMoreMixin from '@/components/mescroll-uni/mixins/mescroll-more.js';
	import meTable from '@/components/me-table.vue';
	import goodsListItem from './goodsListItem.vue';
	import storeService from '@/service/store/store.service.js';
	import fabButton from '@/components/uni-fab.vue';

	import {
		ESCROW_TYPE,
	} from '@/service/store/mapping/enum.js';
	export default {
		components: {
			meTable,
			fabButton,
			goodsListItem,
		},
		mixins: [MescrollMoreMixin, ],
		data() {
			return {
				searchKey: '',
        detailInfo: {},
				customStyle: {
					padding: '30rpx',
				},
				user: this.$storage.get(this.$rp.common.USER),
				plTitle: '案件名称/案件编号'
			};
		},
		mounted() {

		},
    onLoad() {
      this.detailInfo = this.getRouteParam();
      if(this.detailInfo){
        this.searchKey = this.detailInfo.qrCode
        console.log(this.searchKey)
      }

    },
		methods: {
			getListViewHeight() {
				let p = this.$u.sys().windowHeight - 44 - 57 - 40 - uni.upx2px(10) - this.$u.sys().statusBarHeight + 'px';
				// #ifdef H5-DINGDING || H5-WECHAT
				p = this.$u.sys().windowHeight - uni.upx2px(10) - 57 - 40 - this.$u.sys().statusBarHeight + 'px';
				// #endif
				return p;
			},
			toSearchList(e) {
				this.getMescroll(0).triggerDownScroll();
			},
			loadData(page) {
				let params = {
					page: page.num,
					limit: page.size,
					paras: {},
				};
				let fun = '';
				return new Promise((resolve, reject) => {
                    params.paras.caseCode = this.searchKey;
                    params.paras.caseName = this.searchKey;
                    params.paras.qrCode = this.searchKey;
                    fun = storeService.queryGoodsList;
					fun(params).then((res) => {
							if (res.success) {
								resolve({
									count: res.count,
									data: res.data,
								});
							} else {
								resolve({
									count: 0,
									data: [],
								});
							}
						})
						.catch((e) => {
							this.$u.toast('请求失败:' + e);
							resolve({
								count: 0,
								data: [],
							});
						});
				});
			},
		},
	};
</script>

<style scoped lang="scss">
	// @import '@/style/common/rightMenu.scss';

	page {
		background-color: #f3f4f5;
	}

	.content {
		background-color: #f3f4f5;
		margin-top: 52px;
	}

	.nolicence-search-lay {
		// background-color: #fff;
		position: fixed;
		// #ifndef H5-DINGDING
		top: 44px;
		// #endif
		// #ifdef H5-DINGDING
		top: 0px;
		// #endif
		z-index: 999;
		width: 100%;
		overflow: hidden;
		background-color: #ffffff;
		border-bottom: 1px solid $u-border-color;
	}

	.nolicenSearch {
		padding: $cm-search-padding-row $cm-search-padding-column;
	}

	.key-search {
		width: 100%;
		margin: auto;
		padding-left: 2.5%;
		padding-right: 2.5%;
		line-height: 48px;
		border-bottom: 1px solid $u-border-color;
	}

	.pop-content-lay {
		padding: 20rpx;
		display: flex;
		height: 100%;
		flex-direction: column;
		justify-content: center;
	}

	.grid-text {
		font-size: 28rpx;
		margin-top: 4rpx;
		color: $u-type-info;
	}

	.list-lay {
		margin: 10px;
	}

	.list-item-root {
		margin: 10px;
		border-radius: 15px;
		overflow: hidden;
		border-bottom: 1px solid $u-border-color;
		background-color: #fff;
	}

	.u-tabs__wrapper__scroll-view-wrapper {
		width: 100%;
	}
</style>